<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>

 <%
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();
 %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 		<link rel="stylesheet" type="text/css" href="<%=basePath %>/css/updateVideo.css" />
		<link rel="stylesheet" href="<%=basePath %>css/list.css">
		<link href="<%=basePath %>css/H-ui.min.css" rel="stylesheet" type="text/css" />
		<link href="<%=basePath %>/css/H-ui.min.css" rel="stylesheet" type="text/css" />
		<link href="<%=basePath %>/css/formsCSS.css" rel="stylesheet" type="text/css" />
		<script src="<%=basePath %>/js/jquery.min.js"></script>
		<script src="<%=basePath %>/js/formsJS.js"></script>
		<script src="<%=basePath%>/lib/My97DatePicker/WdatePicker.js"></script>
		<!-- kindeditor富文本编辑器 --> 
		<link href="<%=basePath%>/kindeditor/themes/default/default.css">
		<link href="<%=basePath%>/kindeditor/plugins/code/prettify.css">
		<script src="<%=basePath%>/kindeditor/lang/zh-CN.js"></script>
		<script src="<%=basePath%>/kindeditor/kindeditor-all.js"></script>

<script type="text/javascript">

function checkForm(f){

	
	if(f.goodsName.value.replace(/\s/g,'') == ''){
		alert("商品名称不能为空");
		return false;
	}
	
	if(f.goodsTypeCode.value.replace(/\s/g,'') == ''){
		alert("商品分类不能为空");
		return false;
	}
	if(f.goodsPrice.value.replace(/\s/g,'') == ''){
		alert("商品价格不能为空");
		return false;
	}
	
	if(f.goodsStatus.value.replace(/\s/g,'') == ''){
		alert("商品状态不能为空");
		return false;
	}
	 
	if('${type}'=='add'){
		if(f.imgFile.value.replace(/\s/g,'') == ''){
			alert("商品图片不能为空");
			return false;
		}
	}
 
	return true;
}
//添加一行<tr> 
function add() { 
	var content = ""; 
	content += "<div><input type='file' name='goodsImgFiles' class='inputBox'><input type='button' value='删除' onclick='remove(this)'></div>"; 
	 
	$("#fileDiv").append(content); 
} 
//删除当前行<tr> 
function remove(obj) { 
	$(obj).parent().remove(); 
} 

//添加一行<tr> 
function add2() { 
	var content = ""; 
	content += "<div><input type='text' name='paramValues' class='inputBox'><input type='button' value='删除' onclick='remove(this)'></div>"; 
	 
	$("#specificationDiv").append(content); 
} 
 


</script>
</head>
<body>
		<div class="connect_wrap">
    		<h3 style= "text-align: center;">商品信息维护</h3>
			<div class="row cl" style="max-width:88%;margin-left:8%;">
			<div class="labelText"></div>
				<form action="<%=basePath%>/goodsInfo/goodsInfoEdit" method="post" onsubmit="return checkForm(this)"
					enctype="multipart/form-data">
					<div class="col-sm-4"></div>
	    					<div class="col-sm-4">
	    							<div class="boxs">
												<input type="hidden" name="id" value="${goodsInfo.id}"><br />
												<input type="text" class="inputBox" placeholder="商品名称" name="goodsName" value="${goodsInfo.goodsName}" >
												<input type="text" class="inputBox" placeholder="商品副标题" name="goodsTitle" value="${goodsInfo.goodsTitle}" >
												<input type="text" class="inputBox" placeholder="商品作者" name="goodsAuthor" value="${goodsInfo.goodsAuthor}" >
												<select class="selectBox" name="goodsTypeCode" id="goodsTypeCode">
								    				<option value="">----选择商品分类----</option>
									    			<c:forEach items="${goodsTypes}" var="gtp">
									    				<option value="${gtp.typeCode}" ${gtp.typeCode == goodsInfo.goodsTypeCode ? 'selected="selected"' : ''}>${gtp.typeCode}:${gtp.typeName}</option>
									    			</c:forEach>
					    						</select>
												
												<input type="text" class="inputBox" placeholder="商品价格" name="goodsPrice" value="${goodsInfo.goodsPrice}" >
												<input type="text" class="inputBox" placeholder="商品原价" name="orignalPrice" value="${goodsInfo.orignalPrice}" >
												<input type="text" class="inputBox" placeholder="计量单位" name="unit" value="${goodsInfo.unit}" >
												<input type="number" class="inputBox" placeholder="商品库存" name="goodsInventory" value="${goodsInfo.goodsInventory}" >
												<input type="text" class="inputBox" placeholder="商品运费起点" name="freight" value="${goodsInfo.freight}" >
												<select id="goodsStatus" name="goodsStatus" class="selectBox"  >
												  	<option value="">商品状态</option>
										  			<option value="0" ${goodsInfo.goodsStatus == 0 ? 'selected="selected"' : '' }>下线</option>
										  			<option value="1" ${goodsInfo.goodsStatus == 1 ? 'selected="selected"' : '' }>上线</option>
												</select>
												<input type="text" placeholder="上线时间" class="name Wdate inputBox" name="onlineTime" value="${goodsInfo.onlineTime}" 
											    		onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"><br />
				    						    <input type="text" placeholder="下线时间" class="name Wdate inputBox" name="outlineTime" value="${goodsInfo.outlineTime}" 
				    						    		onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"><br />
												<input type="file" class="inputBox" placeholder="商品图片" name="imgFile" value="${goodsInfo.goodsImg}" >
 												<input type="number" class="inputBox" placeholder="商品排序" name="orderNum" value="${goodsInfo.orderNum}" >
												
												<div id="fileDiv">
												 <input type="file" class="inputBox" placeholder="轮播图片"   name="goodsImgFiles" value="${goodsImage.goodsImg}" >
												 <input type="button" id="addButon" value="添加" onclick="add()"> 
												</div>
												<div id="specificationDiv">
													<input type="text" class="inputBox" placeholder="商品规格" name="paramValues" value="${goodsParam.paramValue}" >
													<input type="button" id="addButon2" value="添加" onclick="add2()"> 
												</div>
												<br>
 												<textarea  id="detail" placeholder="商品详情" name="detail" class="inputBox kindeditor" style="width: 90%;">${goodsParam.detail}</textarea>
												
												<input type="submit" value="确定" class="true" />
												<input type="button"  class="false" value="取消" onclick="window.history.go(-1)">
										</div>
								</div>
					</form>
			</div>
	</div>
	
</body>
<script type="text/javascript">
var editor;
KindEditor.ready(function(K) {
	
    editor = K.create('#detail', {
            uploadJson : '<%=basePath%>/kindeditor/upload',       
            fillDescAfterUploadImage: false,
            allowImageRemote:false,
            afterCreate : function() {
                var self = this;
                K.ctrl(document, 13, function() {
                    self.sync();
                });
                K.ctrl(self.edit.doc, 13, function() {
                    self.sync();
                });
            },
            afterBlur:function(){ 
                this.sync(); 
            } 
        });
});  

</script>
	 
</html>